<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function shareTo(stype) {
        var ftit = '';
        var flink = '';
        var lk = '';
        //获取文章标题
        ftit = document.title;
        //获取网页中内容的第一张图片地址作为分享图
        flink = document.images[0].src;
        if (typeof flink == 'undefined') {
            flink = '';
        }
        //当内容中没有图片时，设置分享图片为网站logo
        if (flink == '') {
            lk = 'http://' + window.location.host + '/static/images/logo.png';
        }
        //如果是上传的图片则进行绝对路径拼接
        if (flink.indexOf('/uploads/') != -1) {
            lk = 'http://' + window.location.host + flink;
        }
        //百度编辑器自带图片获取
        if (flink.indexOf('ueditor') != -1) {
            lk = flink;
        }
        //qq空间接口的传参
        if (stype == 'qzone') {
            window.open('https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + document.location.href + '?sharesource=qzone&title=' + ftit + '&pics=' + lk + '&summary=' + "fyukh;");
            //document.querySelector('meta[name="description"]').getAttribute('content')
        }
        //新浪微博接口的传参
        if (stype == 'sina') {
            window.open('http://service.weibo.com/share/share.php?url=' + document.location.href + '?sharesource=weibo&title=' + ftit + '&pic=' + lk + '&appkey=2706825840');
        }
        //生成二维码给微信扫描分享，php生成，也可以用jquery.qrcode.js插件实现二维码生成
        if (stype == 'wechat') {
            window.open('http://zixuephp.net/inc/qrcode_img.php?url=http://localhost:8888/destination/test');
        }
    }
</script>

<div class="fl">分享到：</div>
<div onclick="shareTo('qzone')">
    <img src="http://zixuephp.net/static/images/qqzoneshare.png" width="30">
</div>
<div onclick="shareTo('sina')">
    <img src="http://zixuephp.net/static/images/sinaweiboshare.png" width="36">
</div>
<div onclick="shareTo('wechat')">
    <img src="http://zixuephp.net/static/images/wechatshare.png" width="32">
</div>


</body>
</html>